﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SymWorld.Model;

namespace SymWorld
{
    public partial class Form1 : Form
    {
        private WorldSimulator _worldSimulator = new MinustronPlustronWorldSimulator();
        private int drawIndex = 0;

        public Form1()
        {
            InitializeComponent();
            worldStatePanel.WorldStateRenderer = new Renderer.WorldStateRenderer(_worldSimulator.CurrentWorldState);
        }

        private void timer_Tick(object sender, EventArgs e)
        {
            if (_worldSimulator.CurrentWorldState.ParticleStateList[0].Position.Y > _worldSimulator.CurrentWorldState.ParticleStateList[1].Position.Y)
            { 
            }
            _worldSimulator.CalculateNewWorldState(_worldSimulator.CurrentWorldState.CalculateMinimalParticleDistance()/50d);
            if (drawIndex % 50 == 0)
            {
                worldStatePanel.WorldStateRenderer = new Renderer.WorldStateRenderer(_worldSimulator.CurrentWorldState);
                worldStatePanel.Invalidate();
            }
            this.Text = string.Format("{0}", _worldSimulator.Time);
                
        }
    }
}
